<?php
class Aw_Imagetest_Helper_Catalog_Image extends Mage_Catalog_Helper_Image{

    public function init(Mage_Catalog_Model_Product $product, $attributeName, $imageFile=null)
    {
        $this->_reset();
        $this->_setModel(Mage::getModel('catalog/product_image'));
        $this->_getModel()->setDestinationSubdir($attributeName);
        $this->setProduct($product);
        if(Mage::helper('imagetest')->canWatermark($this->_getModel()->getDestinationSubdir())){
        $this->setWatermark(Mage::getStoreConfig("design/watermark/{$this->_getModel()->getDestinationSubdir()}_image"));
        $this->setWatermarkImageOpacity(Mage::getStoreConfig("design/watermark/{$this->_getModel()->getDestinationSubdir()}_imageOpacity"));
        $this->setWatermarkPosition(Mage::getStoreConfig("design/watermark/{$this->_getModel()->getDestinationSubdir()}_position"));
        $this->setWatermarkSize(Mage::getStoreConfig("design/watermark/{$this->_getModel()->getDestinationSubdir()}_size"));
        }
        if ($imageFile) {
            $this->setImageFile($imageFile);
        }
        else {
            // add for work original size
            $file = $this->getProduct()->getData($this->_getModel()->getDestinationSubdir());
            if ($file)
            {
            	$this->_getModel()->setBaseFile( $file );
            }
        }
        return $this;
    }

}
